﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Security.Cryptography.X509Certificates;
using System.Net;
using pgcd.ServiceWebPPCMPGCD;

namespace pgcd
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void result_Click(object sender, EventArgs e)
        {
            try
            {
                int a = Int32.Parse(premier.Text);
                int b = Int32.Parse(deuxieme.Text);
                int c = 0;
                if (a.ToString()=="" || b.ToString()=="" )
                    MessageBox.Show("tout les champs doivent-etre remplit!");
                else{
                    WebServiceMathSoap12Client web = new WebServiceMathSoap12Client();
                    
                    if (a > b)
                        c = web.PGCD(a, b);
                    else
                        c = web.PGCD(b, a);
                }
                pgcd.Text = c.ToString();
            }
            catch(Exception)
            {
                pgcd.Text = "Erreur ";
            }
        }

        private void ppcm_Click(object sender, EventArgs e)
        {
            try
            {
                int a = Int32.Parse(premier.Text);
                int b = Int32.Parse(deuxieme.Text);
                int c = 0;
                if (a.ToString()=="" || b.ToString()=="" )
                    MessageBox.Show("tout les champs doivent-etre remplit!");
                else{
                    WebServiceMathHttpPostClient web = new WebServiceMathHttpPostClient();
                    
                    if (a > b)
                        c = web.PPCM(a, b);
                    else
                        c = web.PPCM(b, a);
                }
                pgcd.Text = c.ToString();
            }
            catch (Exception)
            {
                pgcd.Text = "Erreur ";
            }
        }
    }
}
